package com.xywl.escort.view.record

import android.os.Bundle
import android.support.v4.content.ContextCompat
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.xywl.escort.R
import com.xywl.escort.base.BaseActivity
import com.xywl.escort.bean.UserFundsListResp
import com.xywl.escort.utils.ToastUtil
import kotlinx.android.synthetic.main.activity_fund_records_detail.*

@Route(path = "/xy/fund/records/detail")
class FundRecordsDetailActivity : BaseActivity() {

    @Autowired
    @JvmField
    var listBean: UserFundsListResp.DataBean.ListBean? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_fund_records_detail)
        ARouter.getInstance().inject(this)

        showBackButton()
        setTitleText(R.string.tips_fund_records)

        if (null == listBean) {
            ToastUtil.showTip(this, "数据错误")
            finish()
        } else {
            val money = listBean!!.moneyYuan
            // 资金流向针对个人(0:入账资金,1:出账资金)
            when (listBean!!.fundsFlowType) {
                0 -> {
                    text_credit_amount.text = "入账金额"
                    text_credit_amount_value.text = "+$money"
                    text_credit_amount_value.setTextColor(ContextCompat.getColor(this, R.color.normal_text_color))
                }
                1 -> {
                    text_credit_amount.text = "出账金额"
                    text_credit_amount_value.text = "-$money"
                    text_credit_amount_value.setTextColor(ContextCompat.getColor(this, R.color.main_body_prompt_color))
                }
            }
            // 操作类型(1:充值,2:提现,3认购,4:收购,5:转卖，6.采购)
            when (listBean!!.operateType) {
                1 -> text_type_value.text = "充值"
                2 -> text_type_value.text = "提现"
                3 -> text_type_value.text = "认购产品"
                4 -> text_type_value.text = "认购产品平台收购"
                5 -> text_type_value.text = "认购产品转卖"
                6 -> text_type_value.text = "商场采购"
                7 -> text_type_value.text = "平台退款"
            }

            text_time_value.text = listBean!!.createTime
            text_order_number_value.text = listBean!!.orderNo
        }
    }
}
